package org.aurora.core.biz.persistence;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.aurora.model.entity.MainSchedulerLockInfo;

import java.util.List;

@Mapper
public interface MainSchedulerMapper {
    @Update("update main_scheduler_lock " +
            "set " +
            "main_scheduler_ip = #{curMainSchedulerIp}, " +
            "main_scheduler_port = #{curMainSchedulerPort}, " +
            "main_scheduler_start_time = #{curMainSchedulerStartTime} " +
            "where " +
            "main_scheduler_ip = #{preMainSchedulerIp} and " +
            "main_scheduler_port = #{preMainSchedulerPort} and " +
            "main_scheduler_start_time = #{preMainSchedulerStartTime}")
    int update(MainSchedulerLockInfo mainSchedulerLockInfo);

    @Select("select " +
            "main_scheduler_ip as pre_main_scheduler_ip, " +
            "main_scheduler_port as pre_main_scheduler_port, " +
            "main_scheduler_start_time as pre_main_scheduler_start_time " +
            "from main_scheduler_lock")
    List<MainSchedulerLockInfo> query();
}
